<% %>
<div id="print" style="font-size:12px;text-align:right;width:100%">
<a href="javascript:window.print();"><%=image_tag"printer.gif",:border=>0,:alt=>'To preview the print result, use File-> Print Preview'.t%><%='Print'.t%></a>
</div>
<table class="TimeTrack">
 <tr>
     <td><%='Report Time Zone'.t%></td>
     <td colspan=2>
     <%=@start_at%> - <%=@end_at%>
     </td>
 </tr>
 <tr>
     <td><%='Selected users'.t%></td>
     <td style="white-space:normal" colspan=2>
       <%@users.each do |u|%>
	     <%=link_to u.name,:controller=>'user',:action=>'show',:id=>u.id%>
       <%end%>
     </td>
 </tr>
 <tr>
   <td><%='Confirm Type'.t%>:</td>
	<td colspan=2><%=@confirmed_time.t%></td>
 </tr>
 <tr>
   <td><%='Work Type'.t%>:</td>
	<td colspan=2><%=@work_time.t%></td>
 </tr>
 <tr>
     <td><%='Include Completed Projects'.t%></td>
	 <td><%= @include_completed_projects == "1" ? "Yes".t : "No".t%>
<tr>
   <th align=left><%='Username'.t%></th>
   <th align=left><table width=100% style="font-weight:bold"><tr><td><%='Project name'.t%></td><td align=center><%='Activity Types'.t%>:<%="hours".t%></td><td align=right><%='User/Project Time Rate'.t%></td></tr></table></th>
 </tr>
 <%
  p_count = 0
  p_total = 0
  user_total_hours = 0 
 %>
 <%@users.each do |user|%>

 <tr>
   <td valign=top width=20% style="border-bottom:2px #ccc solid;">
      <%=link_to user.name,:controller=>"user",:action=>'show',:id=>user.id%>
   </td>
   <td width=80% style="border-bottom:2px #ccc solid;"> 
       <%user_total_hours = user.total_hours(user.id,@start_at,@end_at,@confirmed_time,@work_time) %>
       <%if @include_completed_projects == "1"%>
       <%@projects = user.projects%>
	   <%else%>
       <%@projects = user.active_projects%>
	   <%end%>
	   <table style="border-collapse:collapse" width=100%>
       <%@projects.each do |p|%>
	       <%ut = p.hours(user.id,@start_at,@end_at,@confirmed_time,@work_time)%>
		 <tr>
		   <td valign=top><%=link_to p.name,:controller=>'project',:action=>'show',:id=>p.id%></td>
		   <td align=right width=50%> <%=sprintf('%0.2f',ut)%>
		  </td>
		  <td valign=bottom align=right style="padding:2px;padding-bottom:10px;" width=160>
		   <%=user_total_hours == 0 ? 0 : sprintf("%0.2f",ut*100/user_total_hours)%>%
		     <img src=/images/bar.gif style="width:<%=user_total_hours == 0 ? 0 : ut*100/user_total_hours%>px;height:10px;">
		   </td>
		  </tr>
	   <%end%>
	   <%if user_total_hours>0 %>
	   <tr>
		 <td style="border-top:2px blue solid;border-bottom:0px"><%="Total".t%>:</td>
		 <td align=right style="border-top:2px blue solid;border-bottom:0px;font-weight:bold;font-size:15px;">
		 <%=sprintf('%0.2f',user_total_hours)%></td>
		 <td style="border:0px"></td>
		 </tr>
	   <%end%>
	   </table>
   </td>
 </tr>
 <%
   p_count += 1
   p_total += user_total_hours 
 %>
 <%end%>
 <tr class=th>
  <td><%='Users'.t%>:<%=p_count%></td>
  <td colspan=2><%='Total hours'.t%>:<%=sprintf("%0.2f",p_total)%></td>
 </table>
